import { createAsyncThunk } from '@reduxjs/toolkit';
import { getUserInfoApi } from '@/api/user'

// 创建一个异步操作
export const getUserInfoThunk = createAsyncThunk(
  'user/getUserInfoThunk', // action 类型
  async (_, { rejectWithValue }) => {
    try {
      const res = await getUserInfoApi();
      if (res.status === 0) {
        return res.data;
      } else {
        throw new Error(res.msg);

      }
    } catch (error: any) {
      return rejectWithValue(error.message);
    }
  }
)